<#macro templateTree filepath>
    <@_templateList path=filepath>
        <#list list as a>
            <#if !a.directory><@t.merge 'paths' filepath+'/'+a.fileName/></#if>
        </#list>
        <@_sysLock userId=admin.id itemType='template' itemIds=t.paths><#assign lockMap=map!/></@_sysLock>
        <#if lockMap?has_content>
            <#list lockMap as k,lock>
                <#if lock.userId?has_content><@t.merge 'userIds' lock.userId/></#if>
            </#list>
        </#if>
        <@_sysUser ids=t.userIds><#assign userMap=map!/></@_sysUser>
        <#list list as a>
            <li>
                <#local path=filepath+'/'+a.fileName>
                <@_metadata path=path>
                    <a href="cmsTemplate/${a.directory?then('directory','content')}.html?path=${(path?url)!}"<#if lockMap[path]?has_content><#assign lockUser=(userMap[lockMap[path].userId?string].nickName)!''/>title="<@t.page 'lock.message' lockUser/> ${lockMap[path].createDate}"</#if> target="ajax" rel="cmsTemplateBox">
                        <#if lockMap[path]?has_content><i class="icon-lock icon-large"></i> </#if>${(object.alias)?has_content?then(object.alias+' ('+a.fileName+')',a.fileName)}
                    </a>
                </@_metadata>
            <#if a.directory>
                <ul>
                    <@templateTree path/>
                </ul>
            </#if>
            </li>
        <#else>
            <li><a><@t.page 'empty_directory'/></a></li>
        </#list>
    </@_templateList>
</#macro>
<div class="pageContent">
    <div class="leftPageContent">
        <h2 class="contentTitle">
            <a class="button" href="cmsTemplate/metadata.html" target="ajax" rel="cmsTemplateBox"><@t.page 'template.create'/></a>
            <a class="button" href="cmsTemplate/demo.html" target="dialog" mask="true"><@t.page 'template.example'/></a></li>
        </h2>
        <ul layoutH class="tree treeFolder">
            <@templateTree ''/>
        </ul>
    </div>
    <div id="cmsTemplateBox" class="unitBox rightPageContent">
        <#include "directory.html"/>
    </div>
</div>